#### CALCulate<Chn>:MATH...

This subsystem permits processing of measured data in numerical expression format. The operators are +, -, *, / and use of constants and data arrays are permitted.

Command tree: CALCulate<Chn>:MATH

[:EXPRession]

[:DEFine]

:SDEFine

:FUNCtion

:MEMorize

:STATe

:WUNit

:STATe

##### CALCulate<Chn>:MATH[:EXPRession][:DEFine] <expression>

Defines a simple mathematical relation between traces. To calculate and display the new mathematical trace, the mathematical mode must be switched on (CALCulate<Chn>:MATH:STATe ON
).

This command places some restrictions on the mathematical expression and the operands. Use CALCulate<Chn>:MATH[:EXPRession]:SDEFine
to define general expressions.

<Chn> | Channel number used to identify the active trace. If unspecified the numeric suffix is set to 1.
<expression> | (<operand1><operator1><operand2>[<operator2><operand3>]) The expression must be enclosed in brackets.
Parameters | Operands: See list of trace names Operators: +, -, *, /
*RST value | –
SCPI, Command Types | Confirmed, no query. The defined expression can be queried using CALCulate<Chn>:MATH[:EXPRession]:SDEFine?
Example: | *RST; CALC:MATH:MEM Copy the current state of the default trace Trc1 to a memory trace named 'Mem2[Trc1]'. The memory trace is not displayed. CALC:MATH (CH1DATA / MDATA2) Define a mathematical trace, dividing the data trace by the stored memory trace. The mathematical trace is not displayed CALC:MATH:STAT ON Display the mathematical trace instead of the active data trace.

##### CALCulate<Chn>:MATH[:EXPRession]:SDEFine '<string>'

Defines a general mathematical relation between traces. To calculate and display the new mathematical trace, the mathematical mode must be switched on (CALCulate<Chn>:MATH:STATe ON
).

<Chn> | Channel number used to identify the active trace.
'<string>' | String parameter for the mathematical expression, enclosed in brackets. The string format must correspond to an allowed string in the Define Math dialog.
Parameters | Operands, operators and functions; see table below.
*RST value | –
SCPI, Command Types | Device-specific, command or query. This command also queries a mathematical expression defined via CALCulate<Chn>:MATH[:EXPRession][:DEFine] .
Example: | *RST; CALC:MATH:MEM Copy the current state of the default trace Trc1 to a memory trace named 'Mem2[Trc1]'. The memory trace is not displayed. CALC:MATH:SDEF 'Trc1 / Mem2[Trc1]' Define a mathematical trace, dividing the data trace by the stored memory trace. The mathematical trace is not displayed. CALC:MATH:STAT ON Display the mathematical trace instead of the active data trace.

Expressions defined via CALCulate<Chn>:MATH[:EXPRession]:SDEFine may contain the following elements:

Type | Complete List | Description
Operands | <Trace name> | activeTrc | Mem[activeTrc] | All traces and memory traces of the active setup | active trace | active memory trace assigned to the active trace
Constants | e, pi | 1, -1.2, 8e9 | 1 + 2j, 2 + 1e-9j | Constants | Real values in decimal or exponential format | Complex numbers
Operators | - + , - , * , / , ^ | Basic arithmetic operations; ^ for exponentiation
Functions | linMag (), dBMag (), Arg (), Re (), Im (), log (), ln (), tan (), atan (), sin (), asin (), cos (), acos (), Min ( ... , ... ), Max ( ... , ... ) | Mathematical functions with one or two arguments
Special Functions | StimVal | Current stimulus value (see description of operators for User Defined Math )
Brackets | ( ) | Priority of operations in complex expressions

##### CALCulate<Chn>:MATH:FUNCtion
NORMal | ADD | SUBTract | MULTiply | DIVide

Defines a simple mathematical relation between the active trace
and the active memory trace to calculate a new mathematical trace and displays the mathematical trace.

This command places some restrictions on the mathematical expression and the operands. Use CALCulate<Chn>:MATH[:EXPRession]:SDEFine
to define general expressions.

<Chn> | Channel number used to identify the active trace. If unspecified the numeric suffix is set to 1.
NORMal ADD SUBTract MULTiply DIVide | Math. trace = active data trace Math. trace = data + memory Math. trace = data – memory Math. trace = data * memory Math. trace = data / memory
*RST value | NORMal
SCPI, Command Types | Confirmed, with query.
Example: | *RST; CALC:MATH:MEM Copy the current state of the default trace Trc1 to a memory trace named 'Mem2[Trc1]'. The memory trace is not displayed. CALC:MATH:FUNC DIV Define a mathematical trace, dividing the data trace by the stored memory trace. The mathematical trace is displayed instead of the active data trace. CALC:MATH:STAT? The response is 1 (mathematical mode switched on, mathematical trace displayed).

##### CALCulate<Chn>:MATH:MEMorize

Copies the current state of the active data trace
to a memory trace. If a mathematical trace is active, the data trace associated with the mathematical trace is copied. The memory trace is named Mem<n>[<Data_Trace>] where <n> counts all data and memory traces in the active setup in chronological order, and <Data_Trace> is the name of the associated (copied) data trace.

The exact function of the command depends on the number of memory traces associated to the active data trace:

- If no memory trace is associated to the active trace, a new memory trace is generated.

- If several memory traces are associated to the active trace, the current measurement data overwrites the last generated or changed memory trace.

To copy a trace to the memory without overwriting an existing memory trace or define a memory trace name, use TRACe:COPY <memory_trc>,<data_trc>
. To copy an active mathematical trace use TRACe:COPY:MATH <memory_trc>,<data_trc>

<Chn> | Channel number used to identify the active trace.
*RST value | –
SCPI, Command Types | Device-specific, no query
Example: | *RST; CALC:MATH:MEM Copy the current state of the default trace Trc1 to a memory trace named 'Mem2[Trc1]'. The memory trace is not displayed. DISP:WIND:TRAC2:FEED 'Mem2[Trc1]' Display the created memory trace in the active diagram area (diagram area no. 1).

##### CALCulate<Chn>:MATH:STATe <Boolean>

Activates or deactivates the mathematical mode where the mathematical trace defined via CALCulate<Chn>:MATH[:EXPRession]:SDEFine
is calculated and displayed instead of the active data trace. The command is not valid for mathematical traces calculated via CALCulate<Chn>:MATH:FUNCtion
.

<Chn> | Channel number used to identify the active trace.
<Boolean> | ON - Display the active data trace OFF - Display the mathematical trace
*RST value | OFF
SCPI, Command Types | Confirmed, command or query.
Example: | *RST; CALC:MATH:MEM Copy the current state of the default trace Trc1 to a memory trace named 'Mem2[Trc1]'. The memory trace is not displayed. CALC:MATH:SDEF 'CH1DATA / MDATA2' Define a mathematical trace, dividing the data trace by the stored memory trace. The mathematical trace is not displayed CALC:MATH:STAT ON Display the mathematical trace instead of the active data trace.

##### CALCulate<Chn>:MATH:WUNit[:STATe] <Boolean>

Controls the conversion and formatting of the mathematic expression defined via CALCulate<Chn>:MATH[:EXPRession]:SDEFine
(see Result is Wave Quantity
in the User Def Math dialog).

<Chn> | Channel number used to identify the active trace.
<Boolean> | ON - Result is Wave Quantity enabled; the analyzer assumes that the result of the mathematical expression represents a voltage. OFF - Result is Wave Quantity disabled; the analyzer assumes that the result of the mathematical expression is dimensionless.
*RST value | OFF
SCPI, Command Types | Device-specific, command or query.
Example: | *RST; SWE:TYPE POW Reset the instrument, activate a power sweep, and select a wave quantity a1 for the trace Trc1. CALC:PAR:SDEF 'Trc1', 'a1' Select a wave quantity a1 for the trace Trc1. DISP:WIND:TRAC:FEED 'Trc1' Display the generated trace in the active window. CALC:MATH:SDEF 'StimVal'; STAT ON Define a mathematical trace, dividing the data trace by the stored memory trace. Display the mathematical trace instead of the active data trace. CALC:MATH:WUN ON Take into account that the stimulus value is a voltage (derived from the source power) rather than a dimensionless quantity. The y-axis range of the mathematical trace now exactly corresponds to the power sweep range.